home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / aplictns / plplot26 / part08 < prev    next >
Encoding:
Internet Message Format  |  1990-01-14  |  43.8 KB

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i009: plplot 2.6 - C library for making scientific plots, Part08/12
  5. Message-ID: <10981@xanth.cs.odu.edu>
  6. Date: 14 Jan 90 23:31:51 GMT
  7. Sender: tadguy@cs.odu.edu
  8. Reply-To: Anthony M. Richardson <amr@dukee.egr.duke.edu>
  9. Lines: 1259
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11.  
  12. Submitted-by: Anthony M. Richardson <amr@dukee.egr.duke.edu>
  13. Posting-number: Volume 90, Issue 009
  14. Archive-name: applications/plplot-2.6/part08
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 8 (of 12)."
  23. # Contents:  Amiga/plmenu.c docs/chapter3.tex
  24. # Wrapped by tadguy@xanth on Sun Jan 14 18:11:55 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'Amiga/plmenu.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Amiga/plmenu.c'\"
  28. else
  29. echo shar: Extracting \"'Amiga/plmenu.c'\" \(16175 characters\)
  30. sed "s/^X//" >'Amiga/plmenu.c' <<'END_OF_FILE'
  31. X#include "plplot.h"
  32. X#include "plamiga.h"
  33. X#include <math.h>
  34. X
  35. Xvoid eventwait()
  36. X{
  37. X   for(;;) {
  38. X      /* Wait for message */
  39. X      Wait(1<<PLWindow->UserPort->mp_SigBit);
  40. X      if(procmess())
  41. X         return;
  42. X   }
  43. X}
  44. X
  45. XPLINT procmess()
  46. X{
  47. X   ULONG class;
  48. X   USHORT code;
  49. X   struct IntuiMessage *message;
  50. X
  51. X   while(message = (struct IntuiMessage *)GetMsg(PLWindow->UserPort)) {
  52. X      class = message->Class;
  53. X      code = message->Code;
  54. X      ReplyMsg((struct Message *)message);
  55. X      if(eventhandler(class,code))
  56. X         return((PLINT)1);
  57. X   }
  58. X   return((PLINT)0);
  59. X}
  60. X
  61. XPLINT eventhandler(class, code)
  62. XULONG class;
  63. XUSHORT code;
  64. X{
  65. X   switch (class) {
  66. X      case CLOSEWINDOW:
  67. X         return((PLINT)1);
  68. X      case MENUPICK:
  69. X         menuselect(class,code);
  70. X         break;
  71. X      case SIZEVERIFY:
  72. X         break;
  73. X      case NEWSIZE:
  74. X         if(!(PLCurPrefs.WinType & PLCUST)) {
  75. X            PLCurPrefs.WWidth = PLWindow->Width;
  76. X            PLCurPrefs.WHeight = PLWindow->Height;
  77. X         }
  78. X         else {
  79. X            PLCurPrefs.CWidth = PLWindow->Width;
  80. X            PLCurPrefs.CHeight = PLWindow->Height;
  81. X         }
  82. X         setlimits();
  83. X         disablegads(0);
  84. X         disablemenus();
  85. X         remakeplot();
  86. X         enablemenus();
  87. X         enablegads();
  88. X         break;
  89. X      default:
  90. X         break;
  91. X   }
  92. X
  93. X   return((PLINT)0);
  94. X}
  95. X
  96. Xstruct IntuiText IText0ItemScrSubs[] = {
  97. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"WorkBench", NULL},
  98. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Custom", NULL}
  99. X};
  100. X
  101. Xstruct MenuItem Menu0ItemScrSubs[] = {
  102. X   {
  103. X      &Menu0ItemScrSubs[1],
  104. X      0, 0, 0, 0,
  105. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  106. X      0xFFFE,
  107. X      (APTR)&IText0ItemScrSubs[0],
  108. X      NULL,
  109. X      NULL,
  110. X      NULL,
  111. X      NULL
  112. X   },
  113. X   {
  114. X      NULL,
  115. X      0, 0, 0, 0,
  116. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  117. X      0xFFFD,
  118. X      (APTR)&IText0ItemScrSubs[1],
  119. X      NULL,
  120. X      NULL,
  121. X      NULL,
  122. X      NULL
  123. X   }
  124. X};
  125. X
  126. Xstruct IntuiText IText0ItemPriSubs[] = {
  127. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Bitmap Dump", NULL},
  128. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Full Page (Landscape)", NULL},
  129. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Full Page (Portrait)", NULL}
  130. X};
  131. X
  132. Xstruct MenuItem Menu0ItemPriSubs[] = {
  133. X   {
  134. X      &Menu0ItemPriSubs[1],
  135. X      0, 0, 0, 0,
  136. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  137. X      NULL,
  138. X      (APTR)&IText0ItemPriSubs[0],
  139. X      NULL,
  140. X      NULL,
  141. X      NULL,
  142. X      NULL
  143. X   },
  144. X   {
  145. X      &Menu0ItemPriSubs[2],
  146. X      0, 0, 0, 0,
  147. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  148. X      NULL,
  149. X      (APTR)&IText0ItemPriSubs[1],
  150. X      NULL,
  151. X      NULL,
  152. X      NULL,
  153. X      NULL
  154. X   },
  155. X   {
  156. X      NULL,
  157. X      0, 0, 0, 0,
  158. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  159. X      NULL,
  160. X      (APTR)&IText0ItemPriSubs[2],
  161. X      NULL,
  162. X      NULL,
  163. X      NULL,
  164. X      NULL
  165. X   }
  166. X};
  167. X
  168. Xstruct IntuiText IText0[] = {
  169. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Save Configuration",NULL},
  170. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Reset",NULL},
  171. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Maintain Plot Aspect",NULL},
  172. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Redraw Enabled",NULL},
  173. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Select Screen Type",NULL},
  174. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Print",NULL},
  175. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Save Bitmap as IFF file",NULL}
  176. X};
  177. X
  178. Xstruct MenuItem Menu0Items[] = {
  179. X   {
  180. X      &Menu0Items[1],
  181. X      0, 0, 0, 0,
  182. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  183. X      0,
  184. X      (APTR)&IText0[0],
  185. X      NULL,
  186. X      NULL,
  187. X      NULL,
  188. X      NULL
  189. X   },
  190. X   {
  191. X      &Menu0Items[2],
  192. X      0, 0, 0, 0,
  193. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  194. X      0,
  195. X      (APTR)&IText0[1],
  196. X      NULL,
  197. X      NULL,
  198. X      NULL,
  199. X      NULL
  200. X   },
  201. X   {
  202. X      &Menu0Items[3],
  203. X      0, 0, 0, 0,
  204. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  205. X      0,
  206. X      (APTR)&IText0[2],
  207. X      NULL,
  208. X      NULL,
  209. X      NULL,
  210. X      NULL
  211. X   },
  212. X   {
  213. X      &Menu0Items[4],
  214. X      0, 0, 0, 0,
  215. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  216. X      0,
  217. X      (APTR)&IText0[3],
  218. X      NULL,
  219. X      NULL,
  220. X      NULL,
  221. X      NULL
  222. X   },
  223. X   {
  224. X      &Menu0Items[5],
  225. X      0, 0, 0, 0,
  226. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  227. X      0,
  228. X      (APTR)&IText0[4],
  229. X      NULL,
  230. X      NULL,
  231. X      &Menu0ItemScrSubs[0],
  232. X      NULL
  233. X   },
  234. X   {
  235. X      &Menu0Items[6],
  236. X      0, 0, 0, 0,
  237. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  238. X      0,
  239. X      (APTR)&IText0[5],
  240. X      NULL,
  241. X      NULL,
  242. X      &Menu0ItemPriSubs[0],
  243. X      NULL
  244. X   },
  245. X   {
  246. X      NULL,
  247. X      0, 0, 0, 0,
  248. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  249. X      0,
  250. X      (APTR)&IText0[6],
  251. X      NULL,
  252. X      NULL,
  253. X      NULL,
  254. X      NULL
  255. X   }
  256. X};
  257. X
  258. Xstruct IntuiText IText1Item2Subs[] = {
  259. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)" 2", NULL},
  260. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)" 4", NULL},
  261. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)" 8", NULL},
  262. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"16", NULL}
  263. X};
  264. X
  265. Xstruct MenuItem Menu1Item2Subs[] = {
  266. X   {
  267. X      &Menu1Item2Subs[1],
  268. X      0, 0, 0, 0,
  269. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  270. X      0xFFFE,
  271. X      (APTR)&IText1Item2Subs[0],
  272. X      NULL,
  273. X      NULL,
  274. X      NULL,
  275. X      NULL
  276. X   },
  277. X   {
  278. X      &Menu1Item2Subs[2],
  279. X      0, 0, 0, 0,
  280. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  281. X      0xFFFD,
  282. X      (APTR)&IText1Item2Subs[1],
  283. X      NULL,
  284. X      NULL,
  285. X      NULL,
  286. X      NULL
  287. X   },
  288. X   {
  289. X      &Menu1Item2Subs[3],
  290. X      0, 0, 0, 0,
  291. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  292. X      0xFFFB,
  293. X      (APTR)&IText1Item2Subs[2],
  294. X      NULL,
  295. X      NULL,
  296. X      NULL,
  297. X      NULL
  298. X   },
  299. X   {
  300. X      NULL,
  301. X      0, 0, 0, 0,
  302. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT,
  303. X      0xFFF7,
  304. X      (APTR)&IText1Item2Subs[3],
  305. X      NULL,
  306. X      NULL,
  307. X      NULL,
  308. X      NULL
  309. X   }
  310. X};
  311. X
  312. Xstruct IntuiText IText1[] = {
  313. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Interlaced", NULL},
  314. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"High Resolution",NULL},
  315. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Number of Colors",NULL},
  316. X   {0, 1, JAM1, 0, 0, NULL, (UBYTE *)"Set Color Palette",NULL}
  317. X};
  318. X
  319. X
  320. Xstruct MenuItem Menu1Items[] = {
  321. X   {
  322. X      &Menu1Items[1],
  323. X      0, 0, 0, 0,
  324. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  325. X      0,
  326. X      (APTR)&IText1[0],
  327. X      NULL,
  328. X      NULL,
  329. X      NULL,
  330. X      NULL
  331. X   },
  332. X   {
  333. X      &Menu1Items[2],
  334. X      0, 0, 0, 0,
  335. X      ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT | MENUTOGGLE,
  336. X      0,
  337. X      (APTR)&IText1[1],
  338. X      NULL,
  339. X      NULL,
  340. X      NULL,
  341. X      NULL
  342. X   },
  343. X   {
  344. X      &Menu1Items[3],
  345. X      0, 0, 0, 0,
  346. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  347. X      0,
  348. X      (APTR)&IText1[2],
  349. X      NULL,
  350. X      NULL,
  351. X      &Menu1Item2Subs[0],
  352. X      NULL
  353. X   },
  354. X   {
  355. X      NULL,
  356. X      0, 0, 0, 0,
  357. X      ITEMTEXT | ITEMENABLED | HIGHCOMP,
  358. X      0,
  359. X      (APTR)&IText1[3],
  360. X      NULL,
  361. X      NULL,
  362. X      NULL,
  363. X      NULL
  364. X   }
  365. X};
  366. X
  367. Xstruct Menu Menu[] = {
  368. X   {
  369. X      &Menu[1],
  370. X      0, 0, 0, 0,
  371. X      MENUENABLED,
  372. X      "PLPlot",
  373. X      &Menu0Items[0]
  374. X   },
  375. X   {
  376. X      NULL,
  377. X      0, 0, 0, 0,
  378. X      MENUENABLED,
  379. X      "Screen Format",
  380. X      &Menu1Items[0]
  381. X   }
  382. X};
  383. X
  384. Xenum menus { PLMCONTROL, PLMSCREEN };
  385. X
  386. X/* Control menu items */
  387. Xenum menu0items { PLMSAVECONFIG, PLMRECONFIG, PLMASPECT, PLMBUFF,
  388. X                  PLMSCREENTYPE, PLMSCRDUMP, PLMSIFF };
  389. Xenum menu0itemscrsubs { PLMWBENCH, PLMCUSTOM };
  390. Xenum menu0itemprisubs { PLMPRWIN, PLMPRPLAN, PLMPRPPOR };
  391. X
  392. X/* Custom screen menu items */
  393. Xenum menu1items { PLMLACE, PLMHIRES, PLMCOLORS, PLMCOLREQ };
  394. X/* Number color subitems */
  395. Xenum menu1item2subs {PLMC2, PLMC4, PLMC8, PLMC16 };
  396. X
  397. Xvoid MakePLMenu()
  398. X{
  399. X   short mtx, mledge;
  400. X   short itx, itxlen, itedge, ichk;
  401. X   short stx, stxlen, stedge, schk;
  402. X   short fheight;
  403. X   char *string;
  404. X   struct Menu *menu;
  405. X   struct MenuItem *item, *subitem;
  406. X   struct IntuiText *itext;
  407. X
  408. X   fheight = PLScreen->Font->ta_YSize;
  409. X
  410. X   if(PLCurPrefs.WinType & PLCUST)
  411. X      Menu[0].NextMenu = &Menu[1];
  412. X   else
  413. X      Menu[0].NextMenu = NULL;
  414. X
  415. X   mledge = 0;
  416. X   for(menu=Menu; menu!=NULL; menu=menu->NextMenu) {
  417. X      string = (char *)menu->MenuName;
  418. X      mtx = (short)TextLength(PLSRPort,string,(long)strlen(string));
  419. X      /* Leave two character space between menus */
  420. X      mtx += (2*mtx)/strlen(string);
  421. X      menu->LeftEdge = mledge;
  422. X      menu->Width = mtx;
  423. X      mledge += mtx;
  424. X
  425. X      /* Find length of longest menuitem in this menu */
  426. X      itxlen = 0;
  427. X      ichk = 0;
  428. X      for(item=menu->FirstItem; item!=NULL; item=item->NextItem) {
  429. X         itext = (struct IntuiText *)item->ItemFill;
  430. X         string = (char *)itext->IText;
  431. X         itx = (short)TextLength(PLSRPort,string,(long)strlen(string));
  432. X         itxlen = max(itxlen,itx);
  433. X         if(item->Flags & CHECKIT)
  434. X            ichk = 1;
  435. X      }
  436. X      itedge = 0;
  437. X      for(item=menu->FirstItem; item!=NULL; item=item->NextItem) {
  438. X         item->Width = itxlen;
  439. X         item->LeftEdge = 0;
  440. X         item->TopEdge = itedge;
  441. X         item->Height = fheight;
  442. X         if(ichk) {
  443. X            item->Width += CHECKWIDTH;
  444. X            itext = (struct IntuiTest *)item->ItemFill;
  445. X            itext->LeftEdge = CHECKWIDTH;
  446. X         }
  447. X         itedge += fheight;
  448. X         stxlen = 0;
  449. X         schk = 0;
  450. X         for(subitem=item->SubItem;subitem!=NULL;subitem=subitem->NextItem){
  451. X            itext = (struct IntuiText *)subitem->ItemFill;
  452. X            string = (char *)itext->IText;
  453. X            stx = (short)TextLength(PLSRPort,string,(long)strlen(string));
  454. X            stxlen = max(stxlen,stx);
  455. X            if(subitem->Flags & CHECKIT)
  456. X               schk = 1;
  457. X         }
  458. X         stedge = 0;
  459. X         for(subitem=item->SubItem;subitem!=NULL;subitem=subitem->NextItem){
  460. X            subitem->Width = stxlen;
  461. X            subitem->LeftEdge = item->Width/2;
  462. X            subitem->TopEdge = stedge;
  463. X            subitem->Height = fheight;
  464. X            if(schk) {
  465. X               subitem->Width += CHECKWIDTH;
  466. X               itext = (struct IntuiTest *)subitem->ItemFill;
  467. X               itext->LeftEdge = CHECKWIDTH;
  468. X            }
  469. X            stedge += fheight;
  470. X         }
  471. X      }
  472. X   }
  473. X
  474. X   if(PLCurPrefs.WinType & PLCUST) {
  475. X      Menu0ItemScrSubs[PLMCUSTOM].Flags |= CHECKED;
  476. X      Menu0ItemScrSubs[PLMWBENCH].Flags &= ~CHECKED;
  477. X      Menu1Items[PLMLACE].Flags |= ITEMENABLED;
  478. X      Menu1Items[PLMHIRES].Flags |= ITEMENABLED;
  479. X      Menu1Items[PLMCOLORS].Flags |= ITEMENABLED;
  480. X   }
  481. X   else {
  482. X      Menu0ItemScrSubs[PLMCUSTOM].Flags &= ~CHECKED;
  483. X      Menu0ItemScrSubs[PLMWBENCH].Flags |= CHECKED;
  484. X   }
  485. X
  486. X   Menu1Item2Subs[PLMC2].Flags &= ~CHECKED;
  487. X   Menu1Item2Subs[PLMC4].Flags &= ~CHECKED;
  488. X   Menu1Item2Subs[PLMC8].Flags &= ~CHECKED;
  489. X   Menu1Item2Subs[PLMC16].Flags &= ~CHECKED;
  490. X   Menu1Item2Subs[PLCurPrefs.Depth-1].Flags |= CHECKED;
  491. X
  492. X   if(PLCurPrefs.ScrType & PLLACE)
  493. X      Menu1Items[PLMLACE].Flags |= CHECKED;
  494. X   else
  495. X      Menu1Items[PLMLACE].Flags &= ~CHECKED;
  496. X
  497. X   if(PLCurPrefs.ScrType & PLHIRES)
  498. X      Menu1Items[PLMHIRES].Flags |= CHECKED;
  499. X   else
  500. X      Menu1Items[PLMHIRES].Flags &= ~CHECKED;
  501. X
  502. X   if(PLCurPrefs.WinType & PLASP)
  503. X      Menu0Items[PLMASPECT].Flags |= CHECKED;
  504. X   else
  505. X      Menu0Items[PLMASPECT].Flags &= ~CHECKED;
  506. X
  507. X   if(PLCurPrefs.WinType & PLBUFF)
  508. X      Menu0Items[PLMBUFF].Flags |= CHECKED;
  509. X   else
  510. X      Menu0Items[PLMBUFF].Flags &= ~CHECKED;
  511. X
  512. X   SetMenuStrip(PLWindow,Menu);
  513. X}
  514. X
  515. Xvoid disablemenus()
  516. X{
  517. X   OffMenu(PLWindow, PLMCONTROL | SHIFTITEM(NOITEM));
  518. X   OffMenu(PLWindow, PLMSCREEN  | SHIFTITEM(NOITEM));
  519. X}
  520. X
  521. Xvoid enablemenus()
  522. X{
  523. X   OnMenu(PLWindow, PLMCONTROL | SHIFTITEM(NOITEM));
  524. X   OnMenu(PLWindow, PLMSCREEN  | SHIFTITEM(NOITEM));
  525. X}
  526. X
  527. Xvoid menuselect(class, code)
  528. XULONG class;
  529. XUSHORT code;
  530. X{
  531. X   PLINT ItemNumber, MenuNumber, SubNumber;
  532. X   PLINT remake=0;
  533. X   struct MenuItem *Item;
  534. X
  535. X   if(class == VANILLAKEY)
  536. X      ;
  537. X   else if(class == MENUPICK) {
  538. X      while(code != MENUNULL) {
  539. X         Item = ItemAddress(Menu,code);
  540. X         MenuNumber = MENUNUM(code);
  541. X         ItemNumber = ITEMNUM(code);
  542. X         SubNumber = SUBNUM(code);
  543. X         if(MenuNumber == PLMCONTROL) {
  544. X            if(ItemNumber == PLMSAVECONFIG) {
  545. X               if(!(PLCurPrefs.WinType & PLCUST)) {
  546. X                  PLCurPrefs.WXPos = PLWindow->LeftEdge;
  547. X                  PLCurPrefs.WYPos = PLWindow->TopEdge;
  548. X               }
  549. X               else {
  550. X                  PLCurPrefs.CXPos = PLWindow->LeftEdge;
  551. X                  PLCurPrefs.CYPos = PLWindow->TopEdge;
  552. X               }
  553. X               SetPLDefs();
  554. X            }
  555. X            else if(ItemNumber == PLMRECONFIG) {
  556. X               RestorePrefs();
  557. X               remake = 1;
  558. X            }
  559. X            else if(ItemNumber == PLMASPECT) {
  560. X               if(Item->Flags & CHECKED) {
  561. X                  PLCurPrefs.WinType |= PLASP;
  562. X               }
  563. X               else {
  564. X                  PLCurPrefs.WinType &= ~PLASP;
  565. X               }
  566. X               setlimits();
  567. X               disablegads(0);
  568. X               disablemenus();
  569. X               remakeplot();
  570. X               enablemenus();
  571. X               enablegads();
  572. X            }
  573. X            else if(ItemNumber == PLMBUFF) {
  574. X               if(Item->Flags & CHECKED) {
  575. X                  PLCurPrefs.WinType |= PLBUFF;
  576. X               }
  577. X               else {
  578. X                  PLCurPrefs.WinType &= ~PLBUFF;
  579. X               }
  580. X            }
  581. X            else if(ItemNumber == PLMSCREENTYPE) {
  582. X               if(SubNumber == PLMWBENCH) {
  583. X                  if(!(PLCurPrefs.WinType & PLCUST)) goto reselect;
  584. X                  PLCurPrefs.CXPos = PLWindow->LeftEdge;
  585. X                  PLCurPrefs.CYPos = PLWindow->TopEdge;
  586. X                  PLCurPrefs.WinType &= ~PLCUST;
  587. X               }
  588. X               else if(SubNumber == PLMCUSTOM) {
  589. X                  if(PLCurPrefs.WinType & PLCUST) goto reselect;
  590. X                  /* Save wbench window position */
  591. X                  PLCurPrefs.WXPos = PLWindow->LeftEdge;
  592. X                  PLCurPrefs.WYPos = PLWindow->TopEdge;
  593. X                  PLCurPrefs.WinType |= PLCUST;
  594. X               }
  595. X               remake = 1;
  596. X            }
  597. X            else if(ItemNumber == PLMSCRDUMP) {
  598. X               /* Disable system gadgets */
  599. X               disablegads(SubNumber);
  600. X               disablemenus();
  601. X               screendump(SubNumber);
  602. X               enablemenus();
  603. X               enablegads();
  604. X            }
  605. X            else if(ItemNumber == PLMSIFF) {
  606. X               disablegads(0);
  607. X               disablemenus();
  608. X               saveiff();
  609. X               enablemenus();
  610. X               enablegads();
  611. X            }
  612. X         }
  613. X         else if(MenuNumber == PLMSCREEN) {
  614. X            if(ItemNumber == PLMLACE) {
  615. X               if(Item->Flags & CHECKED)
  616. X                  PLCurPrefs.ScrType |= PLLACE;
  617. X               else
  618. X                  PLCurPrefs.ScrType &= ~PLLACE;
  619. X               PLCurPrefs.CWidth = 0;
  620. X               PLCurPrefs.CHeight = 0;
  621. X               remake = 1;
  622. X            }
  623. X            else if(ItemNumber == PLMHIRES) {
  624. X               if(Item->Flags & CHECKED)
  625. X                  PLCurPrefs.ScrType |= PLHIRES;
  626. X               else
  627. X                  PLCurPrefs.ScrType &= ~PLHIRES;
  628. X               PLCurPrefs.CWidth = 0;
  629. X               PLCurPrefs.CHeight = 0;
  630. X               remake = 1;
  631. X            }
  632. X            else if(ItemNumber == PLMCOLORS) {
  633. X               if(SubNumber == PLMC2) {
  634. X                  if(PLCurPrefs.Depth == 1) goto reselect;
  635. X                  PLCurPrefs.Depth = 1;
  636. X               }
  637. X               else if(SubNumber == PLMC4) {
  638. X                  if(PLCurPrefs.Depth == 2) goto reselect;
  639. X                  PLCurPrefs.Depth = 2;
  640. X               }
  641. X               else if(SubNumber == PLMC8) {
  642. X                  if(PLCurPrefs.Depth == 3) goto reselect;
  643. X                  PLCurPrefs.Depth = 3;
  644. X               }
  645. X               else if(SubNumber == PLMC16) {
  646. X                  if(PLCurPrefs.Depth == 4) goto reselect;
  647. X                  PLCurPrefs.Depth = 4;
  648. X               }
  649. X               PLCurPrefs.CXPos = PLWindow->LeftEdge;
  650. X               PLCurPrefs.CYPos = PLWindow->TopEdge;
  651. X               remake = 1;
  652. X            }
  653. X            else if(ItemNumber == PLMCOLREQ) {
  654. X               disablegads(1);
  655. X               disablemenus();
  656. X               plcolreq();
  657. X               enablemenus();
  658. X               enablegads();
  659. X            }
  660. X         }
  661. Xreselect:
  662. X         code = Item->NextSelect;
  663. X      }
  664. X   }
  665. X   if(remake) {
  666. X      ClosePLWind();
  667. X      OpenPLWind();
  668. X      setlimits();
  669. X      disablegads(0);
  670. X      disablemenus();
  671. X      remakeplot();
  672. X      enablemenus();
  673. X      enablegads();
  674. X   }
  675. X}
  676. X
  677. END_OF_FILE
  678. if test 16175 -ne `wc -c <'Amiga/plmenu.c'`; then
  679.     echo shar: \"'Amiga/plmenu.c'\" unpacked with wrong size!
  680. fi
  681. # end of 'Amiga/plmenu.c'
  682. fi
  683. if test -f 'docs/chapter3.tex' -a "${1}" != "-c" ; then 
  684.   echo shar: Will not clobber existing file \"'docs/chapter3.tex'\"
  685. else
  686. echo shar: Extracting \"'docs/chapter3.tex'\" \(24805 characters\)
  687. sed "s/^X//" >'docs/chapter3.tex' <<'END_OF_FILE'
  688. X\chapter {Advanced Use of PLPLOT}\label{advanced}
  689. X
  690. XIn this chapter, we describe more precisely how to control the position
  691. Xand scaling of a graph, how to alter the low-level line and character
  692. Xattributes, and how to use the functions in PLPLOT for drawing
  693. Xthree-dimensional surface plots and contour plots.
  694. X
  695. X\section {Basic PLPLOT Concepts}
  696. X
  697. XWhen drawing a graph, the programmer usually wishes to specify the
  698. Xcoordinates of the points to be plotted in terms of the values of the
  699. Xvariables involved. These coordinates are called {\em world
  700. Xcoordinates}, and may have any floating-point value representable by the
  701. Xcomputer. The {\em window} refers to the rectangular region of
  702. Xworld-coordinate space which is to be graphed. This window is mapped
  703. Xonto a rectangular region of the {\em view surface}, which is (a
  704. Xportion) of the screen or sheet of paper in the output device. This
  705. Xphysical region onto which the window is mapped is called the {\em
  706. Xviewport}. Before a graph can be drawn, the program must define both the
  707. Xwindow and the viewport by calling appropriate routines in PLPLOT.
  708. X
  709. X\section {Specifying the View Surface}
  710. X
  711. XThe first thing that a graphics program must do is to tell PLPLOT which
  712. Xdevice it is going to use, and how this device is to be divided up for
  713. Xgraph plotting. There are two routines that do this, \rou{plstar}, which
  714. Xprompts at the console for the output device type and \rou{plbeg}, which
  715. Xexpects to be supplied the code number of the device as an argument. The
  716. Xcode numbers required by {\tt plbeg} are the same as displayed by {\tt
  717. Xplstar} when it prompts for a device.
  718. X
  719. XBesides selecting the device, {\tt plstar} and {\tt plbeg} allow the
  720. Xuser to divide the output device plotting area into several subpages of
  721. Xequal size, each of which can be used separately. The routine {\tt
  722. Xpladv} is used to advance to a particular subpage or to the next
  723. Xsubpage. The screen is cleared or a new piece of paper is loaded, if a
  724. Xnew subpage is requested when there are no subpages left on the current
  725. Xpage. When a page is divided into subpages, the default character,
  726. Xsymbol and tick sizes are scaled inversely as the square root of the
  727. Xnumber of subpages in the vertical direction.
  728. X
  729. XAt the end of a plotting program, it is important to close the plotting
  730. Xdevice by calling \rou{plend}. This flushes any
  731. Xinternal buffers and frees any memory that may have been allocated.
  732. XNote that if {\tt plstar}
  733. Xor {\tt plbeg} is called more than once during a program to
  734. Xchange the output device, an automatic call to {\tt plend} is made
  735. Xbefore the new device is opened.
  736. X
  737. X\section {Defining the Viewport} \label{viewport}
  738. X
  739. XAfter defining the view surface, it is necessary to define the portion
  740. Xof this surface which is to be used for plotting the graph. All lines
  741. Xand symbols (except for labels drawn by {\tt plbox}, {\tt plmtex} and
  742. X{\tt pllab}) are clipped at the viewport boundaries.
  743. X
  744. XViewports are created within the current subpage. If the division of the
  745. Xoutput device into equally sized subpages is inappropriate, it is best
  746. Xto specify only a single subpage which occupies the entire output device
  747. X(by setting {\tt nx=1} and {\tt ny=1} in {\tt plbeg} or {\tt plstar}),
  748. Xand use one of the viewport specification subroutines below to place the
  749. Xplot in the desired position on the page.
  750. X
  751. XThere are two methods for specifying the viewport size, using the
  752. Xsubroutines \rou{plvpor} and \rou{plsvpa}. Each of these has the format:
  753. X\begin{verbatim}
  754. Xplvpor(xmin,xmax,ymin,ymax);
  755. Xplsvpa(xmin,xmax,ymin,ymax);
  756. X\end{verbatim}
  757. Xwhere in the case of {\tt plvpor}, the arguments are given in {\em
  758. Xnormalized subpage coordinates} which are defined to run from 0.0 to 1.0
  759. Xalong each edge of the subpage. Thus for example,
  760. X\begin{verbatim}
  761. Xplvpor(0.0,0.5,0.5,1.0);
  762. X\end{verbatim}
  763. Xuses the top left quarter of the current subpage.
  764. X
  765. XIn order to get a graph of known physical size, the routine {\tt plsvpa}
  766. Xdefines the viewport in terms of absolute
  767. Xcoordinates (millimetres) measured from the bottom left-hand corner of
  768. Xthe current subpage. This routine should only be used when the size of
  769. Xthe view surface is known, and a definite scaling is required.
  770. X
  771. XTo help the user call {\tt plsvpa} correctly, the routine \rou{plgspa}
  772. Xis provided which returns the positions of the extremities of the
  773. Xcurrent subpage measured in millimetres from the bottom left-hand corner
  774. Xof the device. Thus, if to set up a viewport with a 10.0~mm margin
  775. Xaround it within the current subpage, the following sequence of calls
  776. Xmay be used
  777. X\begin{verbatim}
  778. Xplgspa(xmin,xmax,ymin,ymax);
  779. Xplsvpa(10.0,xmax-xmin-10.0,10.0,ymax-ymin-10.0);
  780. X\end{verbatim}
  781. XA further routine \rou{plvsta} is available which sets up a standard
  782. Xviewport within the current subpage with suitable margins on each side
  783. Xof the viewport. This may be used for simple graphs, as it leaves enough
  784. Xroom for axis labels and a title. This standard viewport is that used by
  785. X{\tt plenv} (see Section \ref{plenv-sec}).
  786. X
  787. X\section {Defining the Window} \label{window}
  788. X
  789. XThe window must be defined after the viewport in order to map the world
  790. Xcoordinate rectangle into the viewport rectangle. The routine
  791. X\rou{plwind} is used to specify the rectangle in world-coordinate space.
  792. XFor example, if we wish to plot a graph showing the collector current
  793. X$I_C$ as a function of the collector to emitter voltage $V_{CE}$ for a
  794. Xtransistor where $0\le I_C\le 10.0\mbox{\,mA}$ and $0\le V_{CE}\le
  795. X12.0\mbox{\,V}$, we would call the function {\tt plwind} as follows:
  796. X\begin{verbatim}
  797. Xplwind(0.0,12.0,0.0,10.0);
  798. X\end{verbatim}
  799. XNote that each of the arguments is a floating point number, and so the
  800. Xdecimal points are required. If the order of either the X~limits or
  801. XY~limits is reversed, the corresponding axis will point in the opposite
  802. Xsense, (i.e., right to left for X and top to bottom for Y). The window
  803. Xmust be defined before any calls to the routines which actually draw the
  804. Xdata points. Note however that {\tt plwind} may also be called to change
  805. Xthe window at any time. This will affect the appearance of objects drawn
  806. Xlater in the program, and is useful for drawing two or more graphs with
  807. Xdifferent axes on the same piece of paper.
  808. X
  809. X\section {Annotating the Viewport}
  810. X
  811. XThe routine \rou{plbox} is used to specify whether a frame is drawn around
  812. Xthe viewport and to control the positions of the axis subdivisions and
  813. Xnumeric labels. For our simple graph of the transistor characteristics,
  814. Xwe may wish to draw a frame consisting of lines on all four sides of the
  815. Xviewport, and to place numeric labels along the bottom and left hand side.
  816. XWe can also tell PLPLOT to choose a suitable tick interval and
  817. Xthe number of subticks between the major divisions based upon the
  818. Xdata range specified to {\tt plwind}. This is done using the following
  819. Xstatement
  820. X\begin{verbatim}
  821. Xplbox("bcnst",0.0,0,"bcnstv",0.0,0);
  822. X\end{verbatim}
  823. XAnother routine \rou{pllab} provides for text labels for the bottom,
  824. Xleft hand side and top of the viewport. These labels are not clipped,
  825. Xeven though they lie outside the viewport (but they are clipped at the
  826. Xsubpage boundaries). {\tt pllab} actually calls the more general routine
  827. X{\tt plmtex} which can be used for plotting labels at any point relative
  828. Xto the viewport. For our example, we may use
  829. X\begin{verbatim}
  830. Xpllab("V#dCE#u (Volts)","I#dC#u (mA)","TRANSISTOR CHARACTERISTICS");
  831. X\end{verbatim}
  832. XNote that \verb+#d+ and \verb+#u+ are escape sequences (see page
  833. X\pageref{escape}) which allow
  834. Xsubscripts and superscripts to be used in text.
  835. XThey are described more
  836. Xfully later in this chapter.
  837. X
  838. XThe heights of characters used for the axis and graph labels can be
  839. Xchanged by means of the routine \rou{plschr}.
  840. X
  841. X\section {The Routine {\tt plenv}}\label{plenv-sec}
  842. X
  843. XHaving to call {\tt pladv}, {\tt plvpor}, {\tt plwind} and {\tt plbox}
  844. Xis excessively cumbersome for drawing simple graphs. Subroutine {\tt plenv}
  845. Xcombines all four of these in one subroutine, using the
  846. Xstandard viewport, and a limited subset of the capabilities of {\tt plbox}.
  847. XFor example, the graph described above could be initiated by the call:
  848. X\begin{verbatim}
  849. Xplenv(0.0,12.0,0.0,10.0,0,0);
  850. X\end{verbatim}
  851. Xwhich is equivalent to the following series of calls:
  852. X\begin{verbatim}
  853. Xpladv(0);
  854. Xplvsta();
  855. Xplwind(0.0,12.0,0.0,10.0);
  856. Xplbox("bcnst",0.0,0,"bcnstv",0.0,0);
  857. X\end{verbatim}
  858. X
  859. X\section {Setting Line Attributes}
  860. X
  861. XThe graph drawing routines may be freely mixed with those described in
  862. Xthis section which allow the user to control line color, width and styles.
  863. XThe attributes set up by these routines apply modally, i.e, all subsequent
  864. Xobjects (lines, characters and symbols) plotted until the next change in
  865. Xattributes are affected in the same way. The only exception to this rule
  866. Xis that characters and symbols are not affected by a change in the line
  867. Xstyle, but are always drawn using a continuous line.
  868. X
  869. XLine color \label{color} is set using the routine \rou{plcol}. The
  870. Xargument is ignored for devices which can only plot in one color but some
  871. Xterminals support line erasure by plotting in color zero.
  872. X
  873. XLine width \label{width} is set using \rou{plwid}. This option is not
  874. Xsupported by all devices.
  875. X
  876. XLine style \label{style} is set using the routine \rou{plstyl}
  877. Xor \rou{pllsty}. A broken
  878. Xline is specified in terms of a repeated pattern consisting of marks
  879. X(pen down) and spaces (pen up). The arguments to this routine are
  880. Xthe number of elements in the line, followed by two pointers to
  881. Xinteger arrays specifying
  882. Xthe mark and space lengths in micrometers. Thus a line consisting of
  883. Xlong and short dashes of lengths 4\,mm and 2\,mm, separated by spaces of
  884. Xlength 1.5\,mm is specified by:
  885. X\begin{verbatim}
  886. Xmark[0]=4000;
  887. Xmark[1]=2000;
  888. Xspace[0]=1500;
  889. Xspace[1]=1500;
  890. Xplstyl(2,mark,space);
  891. X\end{verbatim}
  892. XTo return to a continuous line, just call {\tt plstyl} with first argument
  893. Xset to zero. You can use {\tt pllsty} to chose between 8 different
  894. Xpredefined styles.
  895. X
  896. X\section {Setting the Area Fill Pattern}
  897. XThe routine \rou{plpat} can be used to set the area fill pattern. The
  898. Xpattern consists of 1 or 2 sets of parallel lines with specified
  899. Xinclinations and spacings. The arguments to this routine are the
  900. Xnumber of sets to use (1 or 2) followed by two pointers to integer
  901. Xarrays (of 1 or 2 elements) specifying the inclinations in tenths
  902. Xof a degree and the spacing in micrometers. (The inclination should
  903. Xbe between -900 and 900.) Thus to specify an area fill pattern consisting
  904. Xof horizontal lines spaced 2\,mm apart use:
  905. X\begin{verbatim}
  906. X*inc=0;
  907. X*del=2000;
  908. Xplpat(1,inc,del);
  909. X\end{verbatim}
  910. XTo set up a symmetrical crosshatch pattern with lines directed 30 degrees
  911. Xabove and below the horizontal and spaced 1.5\,mm apart use:
  912. X\begin{verbatim}
  913. X*inc=300;
  914. X*(inc+1)=-300;
  915. X*del=1500;
  916. X*(del+1)=1500;
  917. Xplpat(2,inc,del);
  918. X\end{verbatim}
  919. X
  920. XThe routine \rou{plpsty} can be used to select from 1 of 8 predefined
  921. Xpatterns.
  922. X
  923. XThe area fill routines also use the current line style, width and
  924. Xcolors to give a virtually infinite number of different patterns!
  925. X
  926. X\section {Setting Character and Symbol Attributes}
  927. X
  928. XThere are two character sets included with PLPLOT. These are known as
  929. Xthe standard and extended character sets respectively. The standard
  930. Xcharacter set is a subset of the extended set. It contains 177
  931. Xcharacters including the ascii characters in a normal style font,
  932. Xthe greek alphabet and several plotter symbols. The extended character
  933. Xset contains almost 2000 characters, including four font styles,
  934. Xand several math, musical and plotter symbols.
  935. X
  936. XThe standard character set is loaded into memory automatically when
  937. X{\tt plstar} or {\tt plbeg} is called. The extended character set
  938. Xis loaded by calling \rou{plfontld}. (The extended character set eats
  939. Xup about 50 kbytes of memory whereas the standard set takes
  940. Xup about 5 kbytes.) {\tt plfontld} can be used to switch between the
  941. Xextended and standard sets. (One set is unloaded before the next is
  942. Xloaded.)
  943. X
  944. XWhen the extended character set is loaded there are four different
  945. Xfont styles to choose from. In this case,
  946. Xthe routine \rou{plfont} sets up the default font for all character
  947. Xstrings. It may be over-ridden for (a portion) of a string by using an
  948. Xescape sequence within the text, as described below.
  949. XThe default font (1) is simple and fastest to draw,
  950. Xthe others are useful for presentation plots on a high-resolution
  951. Xdevice.
  952. X
  953. XThe font codes are interpreted as follows:
  954. X\begin{itemize}
  955. X   \item{\tt font = 1}: normal simple font
  956. X   \item{\tt font = 2}: roman font
  957. X   \item{\tt font = 3}: italic font
  958. X   \item{\tt font = 4}: script font
  959. X\end{itemize}
  960. X
  961. XThe routine \rou{plschr} is used to set up the size of subsequent
  962. Xcharacters drawn. The actual height of a character is the product of the
  963. Xdefault character size and a scaling factor. If no call is made to
  964. X{\tt plschr}, the default character size is set up depending on the number
  965. Xof subpages defined in the call to {\tt plstar} or {\tt plbeg}, and the
  966. Xscale is set to
  967. X1.0. Under normal circumstances, it is recommended that the user does not
  968. Xalter the default height, but simply use the scale parameter. This can
  969. Xbe done by calling {\tt plschr} with {\tt def=0.0} and {\tt scale} set to the
  970. Xdesired multiple of the default height. If the default height is to be
  971. Xchanged, {\tt def} is set to the new default height in millimetres, and
  972. Xthe new character height is again set to {\tt def} multiplied by {\tt
  973. Xscale}.
  974. X
  975. XThe routine \rou{plssym} sets up the size of all subsequent symbols
  976. Xdrawn by calls to {\tt plpoin} and {\tt plsym}. It operates analogously
  977. Xto {\tt plschr} as described above.
  978. X
  979. XThe lengths of major and minor ticks on the axes are set up by the routines
  980. X\rou{plsmaj} and \rou{plsmin}.
  981. X
  982. X\section {Escape Sequences in Text} \label{escape}
  983. X
  984. XThe routines which draw text all allow you to include escape
  985. Xsequences in the text to be plotted. These are character sequences
  986. Xwhich are are interpreted as instructions to
  987. Xchange fonts, draw superscripts and subscripts, draw non-ASCII
  988. X(e.g., Greek letters) etc. All escape sequences start with a number
  989. Xsymbol (\verb+#+).
  990. X
  991. XThe following escape sequences are defined:
  992. X\begin{itemize}
  993. X   \item \verb+#u+: move up to the superscript position
  994. X    (ended with \verb+#d+)
  995. X   \item \verb+#d+: move down to subscript position
  996. X    (ended with \verb+#u+)
  997. X   \item \verb+#b+: backspace (to allow overprinting)
  998. X   \item \verb+##+: number symbol
  999. X   \item \verb.#+.: toggle overline mode
  1000. X   \item \verb.#-.: toggle underline mode
  1001. X   \item \verb+#gx+: Greek letter corresponding to Roman letter {\tt x}
  1002. X                     (see below)
  1003. X   \item \verb+#fn+: switch to normal font
  1004. X   \item \verb+#fr+: switch to Roman font
  1005. X   \item \verb+#fi+: switch to italic font
  1006. X   \item \verb+#fs+: switch to script font
  1007. X   \item \verb+#(nnn)+: Hershey character nnn (1 to 4 decimal digits)
  1008. X\end{itemize}
  1009. X
  1010. XSections of text can have an underline or overline appended. For example,
  1011. Xthe string
  1012. X\[
  1013. X{\rm\overline{S}(\underline{freq})}
  1014. X\]
  1015. Xis obtained by specifying \verb."#+S#+(#-freq#-)"..
  1016. X
  1017. XGreek letters are obtained by \verb+#g+ followed by a Roman letter.
  1018. XTable~\ref{greek} shows how these letters map into Greek characters.
  1019. X\begin{table}
  1020. X   \centering
  1021. X   \begin{tabular}{|l|*{12}{c|}}
  1022. X   \hline
  1023. X   Roman&A&B&G&D&E&Z&Y&H&I&K&L&M\\
  1024. X   \hline
  1025. X   Greek&A & B & $\Gamma$ & $\Delta$ & E & Z & H & $\Theta$ & I & K &
  1026. X   $\Lambda$ & M \\
  1027. X   \hline\hline
  1028. X   Roman&N&C&O&P&R&S&T&U&F&X&Q&W\\
  1029. X   \hline
  1030. X   Greek&N & $\Xi$ & O & $\Pi$ & P & $\Sigma$ &
  1031. X   T & $\Upsilon$ & $\Phi$ & X & $\Psi$ & $\Omega$ \\
  1032. X   \hline\hline
  1033. X   Roman&a&b&g&d&e&z&y&h&i&k&l&m\\
  1034. X   \hline
  1035. X   Greek&   $\alpha$ & $\beta$ & $\gamma$ & $\delta$ & $\epsilon$ & $\zeta$ &
  1036. X   $\eta$ & $\theta$ & $\iota$ & $\kappa$ &
  1037. X   $\lambda$ & $\mu$ \\
  1038. X   \hline\hline
  1039. X   Roman&n&c&o&p&r&s&t&u&f&x&q&w\\
  1040. X   \hline
  1041. X   Greek& $\nu$ & $\xi$ & o & $\pi$ & $\rho$ & $\sigma$ &
  1042. X   $\tau$ & $\upsilon$ & $\phi$ & $\chi$ & $\psi$ & $\omega$ \\
  1043. X   \hline
  1044. X   \end{tabular}
  1045. X\caption{Roman characters corresponding to Greek characters}
  1046. X\label{greek}
  1047. X\end{table}
  1048. X
  1049. X\section {Three Dimensional Surface Plots} \label{threed}
  1050. X
  1051. XPLPLOT includes routines that will represent a single-valued function
  1052. Xof two variables as a surface. In this section, we shall assume that
  1053. Xthe function to be plotted is {\tt Z[X][Y]}, where {\tt Z} represents
  1054. Xthe dependent variable and {\tt X} and {\tt Y} represent the independent
  1055. Xvariables.
  1056. X
  1057. XAs usual, we would like to refer to a three dimensional point {\tt (X,Y,Z)}
  1058. Xin terms of some meaningful user-specified coordinate system. These are
  1059. Xcalled {\em three-dimensional world coordinates}. We need to specify the
  1060. Xranges of these coordinates, so that the entire surface is contained within the
  1061. Xcuboid defined by ${\tt xmin}<{\tt x}<{\tt xmax}$,
  1062. X${\tt ymin}<{\tt y}<{\tt ymax}$ and
  1063. X${\tt zmin}<{\tt z}<{\tt zmax}$. Typically, we shall want to view the
  1064. Xsurface from a variety of angles, and to facilitate this, a two-stage
  1065. Xmapping of the enclosing cuboid is performed. Firstly, it is mapped
  1066. Xinto another cuboid called the {\em normalized box} whose size must also
  1067. Xbe specified by the user, and secondly this normalized box is viewed from
  1068. Xa particular azimuth and elevation so that it can be projected onto the
  1069. Xtwo-dimensional window.
  1070. X
  1071. XThis two-stage transformation process allows considerable flexibility in
  1072. Xspecifying how the surface is depicted. The lengths of the sides of the
  1073. Xnormalized box are independent of the world coordinate ranges of each of the
  1074. Xvariables, making it possible to use ``reasonable'' viewing angles even if the
  1075. Xranges of the world coordinates on the axes are very different. The size of the
  1076. Xnormalized box is determined essentially by the size of the two-dimensional
  1077. Xwindow into which it is to be mapped. The normalized box is centred about the
  1078. Xorigin in the $x$ and $y$ directions, but rests on the plane ${\tt z=0}$. It is
  1079. Xviewed by an observer located at altitude {\tt alt} and azimuth {\tt az}, where
  1080. Xboth angles are measured in degrees. The altitude should be restricted to the
  1081. Xrange zero to ninety degrees for proper operation, and represents the viewing
  1082. Xangle above the xy plane. The azimuth is defined so that when {\tt az=0}, the
  1083. Xobserver sees the xz plane face on, and as the angle is increased, the observer
  1084. Xmoves clockwise around the box as viewed from above the xy plane. The azimuth
  1085. Xcan take on any value.
  1086. X
  1087. XThe first step in drawing a surface plot is to decide on the size of the
  1088. Xtwo-dimensional window and the normalized box. For example, we could choose
  1089. Xthe normalized box to have sides of length
  1090. X\begin{verbatim}
  1091. Xbasex=2.0;
  1092. Xbasey=4.0;
  1093. Xheight=3.0;
  1094. X\end{verbatim}
  1095. XA reasonable range for the $x$ coordinate of the two-dimensional
  1096. Xwindow is -2.5 to +2.5, since the length of the diagonal across the base of
  1097. Xthe normalized box is $\sqrt{2^2+4^2} = 2\sqrt{5}$, which fits into this
  1098. Xcoordinate range. A reasonable range for the $y$ coordinate of the two
  1099. Xdimensional window in this case is -2.5 to +4, as the the projection of the
  1100. Xnormalized box lies in this range for the allowed range of viewing angles.
  1101. X
  1102. XThe routine \rou{plwind} or \rou{plenv} is used in the usual way
  1103. Xto establish the size of the two-dimensional window. The routine
  1104. X\rou{plw3d} must then be called to establish the range of the three
  1105. Xdimensional world coordinates, the size of the normalized box and the
  1106. Xviewing angles. After calling {\tt plw3d}, the actual surface is
  1107. Xdrawn by a call to \rou{plot3d}.
  1108. X
  1109. XFor example, if the three-dimensional world-coordinate ranges are
  1110. X$-10.0\le{\tt x}\le 10.0$, $-3.0\le{\tt y}\le +7.0$ and
  1111. X$0.0\le{\tt z}\le 8.0$, we could use the following statements:
  1112. X\begin{verbatim}
  1113. X      xmin2d = -2.5;
  1114. X      xmax2d =  2.5;
  1115. X      ymin2d = -2.5;
  1116. X      ymax2d =  4.0;
  1117. X      plenv(xmin2d,xmax2d,ymin2d,ymax2d);
  1118. X      basex = 2.0;
  1119. X      basey = 4.0;
  1120. X      height = 3.0;
  1121. X      xmin = -10.0;
  1122. X      xmax = 10.0;
  1123. X      ymin = -3.0;
  1124. X      ymax = 7.0;
  1125. X      zmin = 0.0;
  1126. X      zmax = 8.0;
  1127. X      alt = 45.0;
  1128. X      az = 30.0;
  1129. X      side = 1;
  1130. X      plw3d(basex,basey,height,xmin,xmax,ymin,ymax,zmin,zmax,alt,az);
  1131. X      plot3d(x,y,z,ly,nx,ny,opt,side);
  1132. X\end{verbatim}
  1133. X
  1134. XThe values of the function are stored in a two-dimensional
  1135. Xarray {\tt z[][ly]} where the array element {\tt z[i][j]} contains the value
  1136. Xof the function at the point $x_i$, $y_j$. Note that the values of
  1137. Xthe independent variables $x_i$ and $y_j$ do not need to be equally spaced,
  1138. Xbut they must lie on a rectangular grid. Thus two further arrays {\tt x[nx]}
  1139. Xand {\tt y[ny]} are required as arguments to {\tt plot3d} to specify the
  1140. Xvalues of the independent variables. The values in the arrays x and y must
  1141. Xbe strictly increasing with the index. The argument {\tt opt} specifies
  1142. Xhow the surface is outlined. If {\tt opt=1}, a line is drawn representing
  1143. Xz as a function of x for each value of y, if {\tt opt=2}, a line is drawn
  1144. Xrepresenting z as a function of y for each value of x, and if {\tt opt=3},
  1145. Xa net of lines is drawn. The first two options may be preferable if one of
  1146. Xthe independent variables is to be regarded as a parameter, whilst the third
  1147. Xis better for getting an overall picture of the surface. If side is equal to
  1148. Xone then sides are drawn on the figure so that the graph doesn't appear to
  1149. Xfloat.
  1150. X
  1151. XThe routine \rou{plmesh} is similar to {\tt plot3d,} except that it is
  1152. Xused for drawing mesh plots. Mesh plots allow you to see both the top and
  1153. Xbottom sides of a surface mesh, while 3D plots allow you to see the top
  1154. Xside only (like looking at a solid object). The side option is not
  1155. Xavailable with {\tt plmesh.}
  1156. X
  1157. XLabelling a three-dimensional or mesh plot is somewhat more complicated
  1158. Xthan a two
  1159. Xdimensional plot due to the need for skewing the characters in the label
  1160. Xso that they are parallel to the coordinate axes. The routine \rou{plbox3}
  1161. Xthus combines the functions of box drawing and labelling. Its parameters
  1162. Xare described more fully in Chapter \ref{reference}.
  1163. X
  1164. X\section {Contour Plots}\label{contour}
  1165. X
  1166. XA routine is available in PLPLOT which performs a contour plot of data
  1167. Xstored in a two-dimensional array. A contour following algorithm is
  1168. Xused, so that it is possible to use non-continuous line styles.
  1169. X
  1170. XThe routine \rou{plcont} has the form
  1171. X\name{plcont(z,nx,ny,kx,lx,ky,ly,clevel,nlevel,pltr)}
  1172. Xwhere {\tt z} is the two-dimensional array of size ${\tt nx}\times{\tt ny}$
  1173. Xcontaining samples of the function to be contoured. The parameters
  1174. X{\tt kx}, {\tt lx}, {\tt ky} and {\tt ly} specify the portion of {\tt z}
  1175. Xthat is to be considered. The array {\tt clevel} of length {\tt nlevel}
  1176. Xis a list of the desired contour levels.
  1177. X
  1178. XThe path of each contour is initially computed in terms of the values of the
  1179. Xarray indicies which range from {\tt 0} to {\tt nx-1} in the
  1180. Xfirst index and from
  1181. X{\tt 0} to {\tt ny-1} in the second index.
  1182. XBefore these can be drawn in the current
  1183. Xwindow (see page \pageref{window} in Section \ref{window}), it is
  1184. Xnecessary to
  1185. Xconvert from these array indicies into world coordinates. This is done by
  1186. Xpassing a pointer to a user-defined function to {\tt plcont}.  This
  1187. Xfunction pointer is the last argument {\tt pltr}.
  1188. XThis function must be declared as type {\tt void} in the
  1189. Xmodule which calls {\tt plcont}. This transformation function
  1190. Xmust have the parameter list
  1191. X\name{void pltr(x,y,tx,ty);}
  1192. Xwhere {\tt (x,y)}
  1193. Xis the point through which the contour runs expressed in
  1194. Xterms of array indicies, and {\tt (tx,ty)} are pointers to float variables
  1195. Xwhich are the world coordinates of
  1196. Xthe point which corresponds to these indicies.
  1197. X
  1198. XOften, the transformation between array indices and world coordinates can
  1199. Xbe expressed as a linear transformation. A routine is provided within the
  1200. Xlibrary which can be passed to {\tt plcont} as {\tt pltr}. This
  1201. Xtransformation routine is
  1202. X\begin{verbatim}
  1203. X
  1204. X#include "plplot.h"
  1205. X
  1206. Xvoid xform(x,y,tx,ty)
  1207. Xfloat x, y, *tx, *ty;
  1208. X{
  1209. X      extern float tr[];
  1210. X
  1211. X      *tx = tr[0]*x + tr[1]*y + tr[2];
  1212. X      *ty = tr[3]*x + tr[4]*y + tr[5];
  1213. X}
  1214. X\end{verbatim}
  1215. XThus by setting up the values in the array {\tt tr[]}, we can
  1216. Xapply an arbitrary translation, rotation and/or shear to the array before
  1217. Xdrawing out the contours. By defining other transformation subroutines,
  1218. Xit is possible to draw contours wrapped around polar grids etc.
  1219. X
  1220. XAs an example in setting up {\tt tr[]}, suppose that the array {\tt z}
  1221. Xis of size $21 \times 41$ and contains the values of the function
  1222. X$z[x][y]$,
  1223. Xwhere $x$ ranges from 0.0 to 4.0 and $y$ ranges from -8.0 to 8.0.
  1224. XFurthermore,
  1225. Xlet us also suppose that the window (as defined using {\tt plenv} or
  1226. X{\tt plwind}) covers this range of world coordinates.
  1227. XSince we wish the index
  1228. X(0,0) in array {\tt z} to map to (0.0,-8.0) and the index (20,40) to map
  1229. Xto (4.0,8.0), and for there to be no skew in the axes, we should choose
  1230. Xelements of {\tt tr[]} so that
  1231. X\[
  1232. X   \begin{array}{l@{\;=\;}l}
  1233. X   tx & 0.2x \\
  1234. X   ty & 0.4y - 8.
  1235. X   \end{array}
  1236. X\]
  1237. Xand so {\tt tr[0]=0.2}, {\tt tr[1]=0.0}, {\tt tr[2]=0.0},
  1238. X{\tt tr[3]=0.0}, {\tt tr[4]=0.4}, {\tt tr[5]=-8.}.
  1239. X
  1240. END_OF_FILE
  1241. if test 24805 -ne `wc -c <'docs/chapter3.tex'`; then
  1242.     echo shar: \"'docs/chapter3.tex'\" unpacked with wrong size!
  1243. fi
  1244. # end of 'docs/chapter3.tex'
  1245. fi
  1246. echo shar: End of archive 8 \(of 12\).
  1247. cp /dev/null ark8isdone
  1248. MISSING=""
  1249. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1250.     if test ! -f ark${I}isdone ; then
  1251.     MISSING="${MISSING} ${I}"
  1252.     fi
  1253. done
  1254. if test "${MISSING}" = "" ; then
  1255.     echo You have unpacked all 12 archives.
  1256.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1257. else
  1258.     echo You still need to unpack the following archives:
  1259.     echo "        " ${MISSING}
  1260. fi
  1261. ##  End of shell archive.
  1262. exit 0
  1263. -- 
  1264. Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to:
  1265.     amiga@cs.odu.edu    
  1266. or    amiga@xanth.cs.odu.edu    ( obsolescent mailers may need this address )
  1267. or    ...!uunet!xanth!amiga    ( very obsolescent mailers need this address )
  1268.  
  1269. Comments, questions, and suggestions s should be addressed to ``amiga-request''
  1270. (only use ``amiga'' for submissions) at the above addresses.
  1271.